Ext.define('archives.view.base.Grid', {
	extend : 'Ext.grid.Panel',
	
	requires: ['Ext.ux.grid.FiltersFeature'],
    features: {
        ftype: 'filters',
        encode : true
    },
    
    border : false,
	//columnLines : true,
	
	store : Ext.emptyString,
	columns : Ext.emptyString,

	extendColOper : Ext.emptyString,
	
	rightToolBar : Ext.emptyString,
	extendToolBar : Ext.emptyString,
	
	viewConfig : {
		forceFit : true,
		stripeRows : true
	},

	/*listeners: {
        dblclick: {
            element: 'body', //bind to the underlying body property on the panel
            fn: function(){ this.fireEvent('griddbclick'); }
        }
    },*/
    
	initComponent : function() {
		
		var me = this;
		
		Ext.apply(me,{selModel:Ext.create('Ext.selection.CheckboxModel')});
		
		me.callParent(arguments);
		
		var colOper = me.getCol();
		
		if (colOper.length > 0 )
		{
			var colWidth = 20 * colOper.length;
			me.headerCt.insert(0, [{
								menuDisabled : true,
								sortable : false,
								xtype : 'actioncolumn',
								padding : 2,
								width :colWidth,
								items : colOper
							}]);
		};
		
		var toolbar = me.getToolBar();

		if (toolbar.length > 0) {
			var tbar = new Ext.Toolbar();
			tbar.add(toolbar);
			me.addDocked(tbar);
		}

		me.addDocked({
						dock : 'bottom',
						xtype : 'pagingtoolbar',
						store : this.store,
						displayInfo : true
					});
	},
	
	getCol : function()
	{
		var me = this;

		var colOper = [];
		
		if (me.extendColOper.length > 0)
		{
			colOper = colOper.concat(me.extendColOper);
		}
	
		return colOper;
	},
	getToolBar : function()
	{
		var me = this;

		var toolbar = [];
		
		if (me.extendToolBar.length > 0) {
			toolbar = toolbar.concat(me.extendToolBar);
		}
		if (me.rightToolBar.length > 0) {
			toolbar = toolbar.concat('->');
			toolbar = toolbar.concat(me.rightToolBar);
		}
	
		return toolbar;
	}
})
